﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Eleanor.Website.Utility.Filter
{
    public class PikaQFilter : IActionFilter
    {
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            ControllerBase controller = filterContext.Controller;
        }

        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (PikaQUtility.IsPikaQRequest(filterContext.HttpContext.Request))
            {
                JsonResult originalResult = filterContext.Result as JsonResult;
                if (originalResult != null)
                {
                    PikaQResult result = new PikaQResult(originalResult);
                    filterContext.Result = result;
                }                
            }
        }
    }
}